//
//  TestEditingTableViewController.m
//  wuliangye
//
//  Created by jarze on 16/2/16.
//  Copyright © 2016年 jarze. All rights reserved.
//

#import "TestEditingTableViewController.h"
#import "ViewController.h"
#import "PopNumberViewController.h"
#import "CircleAnimationViewController.h"
#import "HeaderTapViewController.h"
#import "ScratchViewController.h"
#import "EmitterSnowViewController.h"
//#import "POP.h"


#import "CssPointViewController.h"

#import "WeatherHomeViewController.h"
#import "ColorProgressViewController.h"
#import "MusicBarAnimationController.h"
#import "BezierPathViewController.h"
#import "ShakeViewController.h"
#import "ScrollImageViewController.h"
#import "ScrollViewAnimationController.h"


#import "iCarouselViewController.h"
#import "CAShapeLayerPathController.h"

#import "CircleScoreViewController.h"

#import "XiuxiuViewController.h"
#import "FireViewController.h"

#import "HeartViewController.h"
#import "StarViewController.h"
#define randColor [UIColor colorWithRed:arc4random_uniform(255)/255.0 green:arc4random_uniform(255)/255.0 blue:arc4random_uniform(255)/255.0 alpha:1]
@interface TestEditingTableViewController ()
@property (nonatomic, retain)NSMutableArray *data;

@end

@implementation TestEditingTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
//    [self.tableView setEditing:YES];
    
}
- (NSMutableArray *)data
{
    if (_data == nil) {
    
        _data = [NSMutableArray arrayWithObjects:@"POP-按钮动画",@"POP-数值动画,UILabel 混色,果冻效果",@"ESaing-圆环动画",@"UITableView-展开缩放动画",@"刮奖效果",@"粒子动画",@"心电图动画效果",@"画表盘",@"彩色进度条",@"音乐条,CAReplicatorLayer",@"震动效果",@"UIScrollView视差效果动画",@"ScrollView动画",@"旋转木马效果",@"CAShapeLayerPathController",@"分数圆环",@"雷达",@"🔥火焰", @"❤️",@"✨",nil];
    }
    return _data;
}
#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return self.data.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    cell.backgroundColor = randColor;
    // Configure the cell...
    cell.textLabel.text = self.data[indexPath.row];
    
    return cell;
}       


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    switch (indexPath.row) {
        case 0:
        {
            ViewController *vc = [[ViewController alloc] init];
            vc.title = @"POP-按钮动画";
            [self.navigationController pushViewController:vc animated:YES];
            
        }
            break;
         case 1:
        {
            PopNumberViewController *vc = [[PopNumberViewController alloc] init];
            vc.title = @"POP-数值动画";
            [self.navigationController pushViewController:vc animated:YES];
            
        }
            break;
        case 2:
        {
            CircleAnimationViewController *vc = [[CircleAnimationViewController alloc] init];
            vc.title = @"ESaing-圆环动画";
            
            [self showViewController:vc sender:nil];
//            [self.navigationController pushViewController:vc animated:YES];
            
        }
            break;
            
        case 3:
        {
            HeaderTapViewController *vc = [[HeaderTapViewController alloc] init];
            vc.title = @"UITableView-展开缩放动画";
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 4:
        {
            ScratchViewController *vc = [[ScratchViewController alloc] init];
            vc.title = @"刮奖效果";
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 5:
        {
            EmitterSnowViewController *vc = [[EmitterSnowViewController alloc] init];
            vc.title = @"粒子动画";
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 6:
        {
            BezierPathViewController *vc = [[BezierPathViewController alloc] init];
            vc.title = @"心电图动画效果";
            [self.navigationController pushViewController:vc  animated:YES];
        }
            break;
        case 7:
        {
            CssPointViewController *vc = [[CssPointViewController alloc] init];
            vc.title = @"画表盘";
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 8:
        {
            ColorProgressViewController *vc = [[ColorProgressViewController alloc] init];
            vc.title = @"彩色进度条";
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 9:
        {
            MusicBarAnimationController *vc = [[MusicBarAnimationController alloc] init];
            vc.title = @"音乐条";
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 10:
        {
            ShakeViewController *vc = [[ShakeViewController alloc] init];
            vc.title = @"震动效果";
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 11:
        {
            ScrollImageViewController *vc = [[ScrollImageViewController alloc] init];
            vc.title = @"UIScrollView视差效果动画";
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 12:
        {
            ScrollViewAnimationController *vc = [[ScrollViewAnimationController alloc] init];
            vc.title = @"ScrollView动画";
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 13:{
            iCarouselViewController *vc = [[iCarouselViewController alloc] init];
            vc.title = @"旋转木马效果";
            [self.navigationController pushViewController:vc animated:YES];
        
        
        }
            break;
        case 14:{
            CAShapeLayerPathController *vc = [[CAShapeLayerPathController alloc] init];
            vc.title = @"CAShapeLayerPathController";
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 15:{
            CircleScoreViewController *vc = [[CircleScoreViewController alloc] init];
            vc.title = @"分数圆环";
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 16:{
            XiuxiuViewController *vc = [[XiuxiuViewController alloc] init];
            vc.title = @"雷达";
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 17:{
            FireViewController *vc = [[FireViewController alloc] init];
            vc.title = @"火焰";
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 18:{
            HeartViewController *vc = [[HeartViewController alloc] init];
            vc.title = @"心";
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 19:{
            StarViewController *vc = [[StarViewController alloc] init];
            vc.title = @"star";
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        default:
            break;
    }
}





- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
    return  YES;
    
}
//返回编辑的类型1.没有2.删除3.插入
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return UITableViewCellEditingStyleDelete;

}
//删除提示文本
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return @"dsfdsgsdgdfg";
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        [self.data removeObjectAtIndex:indexPath.row];
        [self.tableView deleteRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationAutomatic];
    }
    
}
//
//
//

//- (NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    
//    //设置删除按钮
//    UITableViewRowAction *deleteRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"删除"handler:^(UITableViewRowAction *action,NSIndexPath *indexPath) {
//        
//        [self.data removeObjectAtIndex:indexPath.row];
//        [self.tableView deleteRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationAutomatic];
//        
//    }];
//    
//    //设置收藏按钮
//    UITableViewRowAction *collectRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"收藏"handler:^(UITableViewRowAction *action,NSIndexPath *indexPath) {
//        
//        
//        collectRowAction.backgroundColor = [UIColor greenColor];
//        
//        UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"收藏"message:@"收藏成功"delegate:nil cancelButtonTitle:@"确定"otherButtonTitles:nil,nil];
//        
//        [alertView show];
//        
//        
//    }];
//    //设置置顶按钮
//    UITableViewRowAction *topRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"置顶"handler:^(UITableViewRowAction *action,NSIndexPath *indexPath) {
//        
//        
//        [self.data exchangeObjectAtIndex:indexPath.row withObjectAtIndex:0];
//        
//        NSIndexPath *firstIndexPath = [NSIndexPath indexPathForRow:0 inSection:indexPath.section];
//        
//        [self.tableView moveRowAtIndexPath:indexPath toIndexPath:firstIndexPath];
//        
//    }];
//    
//    collectRowAction.backgroundEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
//    topRowAction.backgroundColor = [UIColor blueColor];
//    collectRowAction.backgroundColor = [UIColor grayColor];
//    
//    return  @[deleteRowAction,collectRowAction,topRowAction];
//}





////返回编辑的类型1.没有2.删除3.插入
//- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    return UITableViewCellEditingStyleNone;
//
//}

- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
    return YES;
}
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath
{
    [self.data exchangeObjectAtIndex:sourceIndexPath.row withObjectAtIndex:destinationIndexPath.row];
    
    [self.tableView moveRowAtIndexPath:sourceIndexPath toIndexPath:destinationIndexPath];
    
}


//- (BOOL)tableView:(UITableView *)tableView canFocusRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    return YES;
//}
//- (void)tableView:(UITableView *)tableView didUpdateFocusInContext:(UITableViewFocusUpdateContext *)context withAnimationCoordinator:(UIFocusAnimationCoordinator *)coordinator
//{
//    
//}
//
//- (NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    
//}
//
//- (void)tableView:(UITableView *)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    
//}

@end
